# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=yaegi
pkgver=0.16.1
pkgrel=0
pkgdesc="Elegant Go interpreter"
url="https://github.com/traefik/yaegi"
# 32bit: TestEvalBuiltin test fails
arch="all !x86 !armhf !armv7"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/traefik/yaegi/archive/refs/tags/v$pkgver.tar.gz"
# Required to pass tests.
# Ref: https://github.com/traefik/yaegi/issues/1523#issuecomment-1465730351
builddir="$srcdir/src/github.com/traefik/$pkgname"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	export GOPATH="$srcdir"

	mkdir -p "$(dirname $builddir)"
	mv "$srcdir/$pkgname-$pkgver" "$builddir"/

	default_prepare
}

build() {
	go build -v -ldflags "-X main.version=v$pkgver" ./cmd/yaegi/
}

check() {
	# Tests in interp module time out on riscv64 after the default 10 minutes.
	GOFLAGS="${GOFLAGS/-trimpath/}" go test -timeout=30m ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
44db8b3748980c60873aef6b2aa7198e34e9c3aec9141ba56c9c91120e38e4d587c4bbfd09b250b52b607c88d1da41b82b31859d90636bf62cfe6d07bd30fea8  yaegi-0.16.1.tar.gz
"
